package com.stylefeng.guns.rest.emailserver;

import com.sun.mail.util.MailSSLSocketFactory;

import java.security.GeneralSecurityException;
import java.util.Properties;

/**
 * @author yuzih
 * @create 2018-05-22 15:20
 * @desc 邮件服务器类
 **/
public class QQEmailServer implements MailServer{
    private Properties properties;

    public QQEmailServer() {
        properties = System.getProperties();
        try {
            MailSSLSocketFactory mailSSLSocketFactory = new MailSSLSocketFactory();
            mailSSLSocketFactory.setTrustAllHosts(true);
            // 设置邮件服务器
            properties.setProperty("mail.smtp.host", "smtp.qq.com");
            properties.put("mail.smtp.auth", "true");
            properties.put("mail.smtp.ssl.enable", "true");
            properties.put("mail.smtp.ssl.socketFactory", mailSSLSocketFactory);
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
        }
    }

    @Override
    public Properties getProperties() {
        return properties;
    }

}
